package com.lemon.exam.controller;

import com.lemon.exam.common.annotation.Web;
import com.lemon.exam.service.HomeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import java.util.Map;

/**
 * 首页控制器
 *
 * @author Lemon
 * @since 2025/4/18 12:13
 */
@RestController
@RequestMapping("home")
@Tag(name = "首页", description = "首页 API")
@Web(childUri = "home", childComponent = "system/Home.vue")
public class HomeController {
    @Resource
    private HomeService homeService;

    /**
     * 获取当前用户信息
     *
     * @return
     */
    @GetMapping("getCurrentUser")
    @Operation(summary = "获取当前用户信息")
    public Mono<Map<String, Object>> getCurrentUser() {
        return homeService.getCurrentUser();
    }

    /**
     * 统计当前用户信息
     *
     * @return
     */
    @GetMapping("statisticsCurrentUser")
    @Operation(summary = "统计当前用户信息")
    public Mono<Map<String, Object>> statisticsCurrentUser(@RequestParam("type") String type) {
        return homeService.statisticsCurrentUser(type);
    }
}
